package com.lefeng.cockpit.admin.api.v1.datax;

import com.didiglobal.logi.security.common.PagingData;
import com.didiglobal.logi.security.common.PagingResult;
import com.didiglobal.logi.security.common.Result;
import com.lefeng.cockpit.common.bean.dto.executor.ExecutorDTO;
import com.lefeng.cockpit.common.bean.vo.execute.ExecutorStateVO;
import com.lefeng.cockpit.common.bean.vo.execute.ExecutorVO;
import com.lefeng.cockpit.datax.service.ExecutorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author weifw
 */
@RestController
@RequestMapping("/api/v1/datax/executor")
@Api(tags = "datax-执行器相关API")
public class JobExecutorController {

    @Resource
    private ExecutorService executorService;


    @PostMapping("/page")
    @ApiOperation(value = "分页执行器列表", notes = "分页和条件查询")
    public PagingResult<ExecutorVO> page(@RequestBody @Validated ExecutorDTO executorDTO) {
        PagingData<ExecutorVO> configVO = executorService.pagingExecutor(executorDTO);
        return PagingResult.success(configVO);
    }

    @GetMapping("/count")
    @ApiOperation(value = "分页执行器列表", notes = "分页和条件查询")
    public Result<ExecutorStateVO> getExecutorState() {
        ExecutorStateVO executorState = executorService.getExecutorState();
        return Result.buildSucc(executorState);
    }


}